package com.monster.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.monster.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select count(1)" +
            "from t_order" +
            "where MEMBER_ID = #{memberID} and SETMEAL_ID = #{setmealId} and ORDERDATE = #{orderDate}")
    Boolean findOrderIsExitBySetmealIdAndOrderDateAndTime(@Param("memberID") int memberID, @Param("setmealId") String setmealId, @Param("orderDate") String orderDate);

    @Update("update t_ordersetting set  RESERVATIONS = RESERVATIONS+1  where id = #{setmealId}")
    Boolean updateOrderSetting(@Param("setmealId") String setmealId);

    @Select("select ts.name as setmeal  ,tm.name as memberName ,tor.ORDERTYPE as orderType, tor.ORDERDATE as orderDate " +
            "            from  t_setmeal ts,t_order tor ,t_member tm " +
            "            where   tor.SETMEAL_ID = ts.id and tor.MEMBER_ID = tm.id " +
            "            and  tm.id = #{id}")
    Map showSuccessPage(int id);

}
